package com.lsc.record.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.lsc.record.common.BooleanResult;
import com.lsc.record.core.entity.DmType;
import com.lsc.record.core.entity.DmTypeAttr;
import com.lsc.record.core.service.FormServcie;
import com.lsc.record.core.service.ListViewServcie;
import com.lsc.record.core.service.TypeService;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryChain;

@RestController
@RequestMapping("/system/config/type")
public class TypeController extends ApiBaseController<DmType> {
    
    @Resource
    private TypeService service;
    
    @Resource
    private FormServcie formService;
    
    @Resource
    private ListViewServcie listViewServcie;
    
	@Override
	public String save(DmType data)  throws Exception{
		
		return null;
	}

	@Override
	public DmType get(String id)  throws Exception{
		
		return null;
	}

	

	@Override
	public Boolean update(DmType data)  throws Exception{
		
		return null;
	}

	@Override
	public Boolean delete(String id)  throws Exception{
		
		return null;
	}

	@Override
	public Page<DmType> page(int pageSize, int pageIndex, JSONObject condition)  throws Exception{
		
		return null;
	}

	@Override
	public List<DmType> list(JSONObject condition)  throws Exception{
		
		return null;
	}

	
	@PostMapping("createSubType")
	public String createSubType(String superId,String typeName,String snCode)  throws Exception{
		DmType type = service.createSubType(superId, typeName, snCode);
		formService.initForm(type);
		listViewServcie.initListView(type);
		return type.getId();
	}
	
	@PostMapping("appendItem")
	public BooleanResult appendItem(@RequestBody DmTypeAttr attr) throws Exception {
		BooleanResult result = service.appendAttr(attr, attr.getTypeId());
		return result;
	}
	
}
